<?php
/**
 * CreateTime: 2023/11/15 10:17
 * User:LinQ
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            // 数据库基本配置
            $table->engine = 'InnoDB';
            $table->unique('order_no','idx_order_no_union');
            $table->id('order_id')->comment('订单id');;
            $table->string('order_no', 50)->comment('订单号');
            $table->integer('user_id')->comment('用户ID');
            $table->integer('goods_id')->nullable(false)->comment('商品id');
            $table->decimal('total_amount', 10, 2)->comment('订单总金额');
            $table->tinyInteger('pay_status')->default(2)->comment('支付状态：2-未支付，1-已支付');
            $table->tinyInteger('pay_type')->default(1)->comment('支付方式：1-微信支付，2-支付宝支付');
            $table->dateTime('pay_time')->nullable()->comment('支付时间');
            $table->string('wx_pay_order_no', 500)->nullable()->comment('微信支付订单号');
            $table->string('wx_mch_id', 500)->nullable()->comment('微信支付商户号');
            $table->string('alipay_trade_no', 500)->nullable()->comment('支付宝交易号');
            $table->string('alipay_buyer_id', 500)->nullable()->comment('支付宝买家用户ID');
            $table->string('alipay_seller_id', 500)->nullable()->comment('支付宝卖家商户号');
            $table->string('shipping_name', 32)->nullable()->comment('收货人姓名');
            $table->string('shipping_phone', 16)->nullable()->comment('收货人电话');
            $table->string('shipping_address', 255)->nullable()->comment('收货地址');
            $table->tinyInteger('order_status')->default(1)->comment('订单状态：1-待支付，2-已支付，3-已发货，4-已完成，5-已关闭');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
};
